package com.swaggerui.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: where
 * @Date: 2022/07/06/16:11
 * @Description:
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket creatDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //配置生成api文档的包名
                .apis(RequestHandlerSelectors.basePackage("com.swaggerui.controller"))
                .paths(PathSelectors.any())
                .build();
                //添加登录安全的认证
                //.securitySchemes(securitySchem())
                //.securityContexts()

    }

    @Bean
    public ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("品牌管理的swagger2Test")
                .description("mymall-swagger2")
                .contact("where")
                .version("1.0")
                .build();
    }
}
